﻿@using Microsoft.AspNetCore.Identity
@using OnlineEducation.Models

@inject SignInManager<ApplicationUser>     SignInManager
@inject UserManager<ApplicationUser>       UserManager

@inject OnlineEducation.Data.ApplicationDbContext context

@{
    ApplicationUser appUser = await UserManager.GetUserAsync(User);

    //var fullName = string.IsNullOrEmpty(appUser.FullName) ? appUser.UserName : appUser.FullName;
    int count = 0;
    bool admin = User.IsInRole("SuperAdmin");
    bool teacher = User.IsInRole("Teacher");
    bool student = User.IsInRole("Student");

    if (student)
    {
        var studentId = User.GetUserID();

        count = context.Bookings.Include(n => n.TeachingPlan).Where(r => r.StudentId == studentId && r.TeachingPlan.Category == 1).Count();
    }

}

@if (SignInManager.IsSignedIn(User))
{
    <!-- ========== Left Sidebar Start ========== -->
    <div class="left-side-menu">

        <div class="slimscroll-menu">

            <!--- Sidemenu -->
            <div id="sidebar-menu">

                <ul class="metismenu" id="side-menu">

                    <li class="menu-title">功能导航</li>
                    @if (admin)
                    {
                        <li>
                            <a href="@Url.Action("Index", "Home", new { area = "" })">
                                <i class="mdi mdi-monitor-dashboard" aria-hidden="true"></i>

                                <span> 仪表盘 </span>
                            </a>

                        </li>

                    }
                    @if (student || teacher)
                    {
                        <li>
                            <a href="@Url.Action("Index", "Home", new { area = "" })">
                                <i class="fe-calendar"></i>
                                @*<span class="badge badge-info badge-pill float-right">40</span>*@
                                <span>  课程日历 </span>
                            </a>

                        </li>
                    }
                    @if (student)
                    {
                        <li>
                            <a href="@Url.Action("Index", "Booking", new { area = "Booking" })">
                                <i class="fa fa-flag" aria-hidden="true"></i>
                                @*<span class="badge badge-info badge-pill float-right">40</span>*@
                                <span> 预定课程 </span>
                            </a>

                        </li>
                        <li class="@Html.IsSelected(controller: "Order")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-account-card-details"></i>
                                <span> 我的 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">


                                <li>
                                    <a href="@Url.Action("Index", "Order", new { area = "Order" })">
                                        @*<i class="fa fa-flag " aria-hidden="true"></i>*@
                                        <span class="badge badge-info badge-pill float-right">@count</span>
                                        <span> 我的课程 </span>
                                    </a>

                                </li>
                                <li>
                                    <a href="@Url.Action("Index", "Profile", new { area = "Profile" })">
                                        @*<i class="fa fa-flag " aria-hidden="true"></i>*@
                                        @*<span class="badge badge-info badge-pill float-right">40</span>*@
                                        <span> 我的资料 </span>
                                    </a>

                                </li>

                            </ul>
                        </li>





                    }
                    @if (teacher)
                    {
                        <li class="@Html.IsSelected(controller: "Course")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-book-open-page-variant"></i>
                                <span> 课程管理 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">


                                <li class="@Html.IsSelected(controller: "Course",action:"Index")">
                                    <a href="@Url.Action("Index", "Course", new { area = "Course" })"> <i class="fa fa-search" aria-hidden="true"></i> 查询课程 </a>
                                </li>
                                <li class="@Html.IsSelected(controller: "Course",action:"Add")">
                                    <a href="@Url.Action("Add", "Course",new { area = "Course" })"><i class="mdi mdi-plus-box  " aria-hidden="true"></i> 添加课程 </a>
                                </li>

                            </ul>
                        </li>
                        <li class="@Html.IsSelected(controller: "TeachingPlan")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-animation-play"></i>
                                <span> 教学计划 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">


                                <li class="@Html.IsSelected(controller: "TeachingPlan",action:"Index")">
                                    <a href="@Url.Action("Index", "TeachingPlan", new { area = "TeachingPlan" })"> <i class="fa fa-search" aria-hidden="true"></i> 查询教学计划 </a>
                                </li>
                                <li class="@Html.IsSelected(controller: "TeachingPlan",action:"Add")">
                                    <a href="@Url.Action("Add", "TeachingPlan", new { area = "TeachingPlan" })"><i class="mdi mdi-library-plus" aria-hidden="true"></i> 添加教学计划 </a>
                                </li>

                            </ul>
                        </li>
                        <li class="@Html.IsSelected(controller: "TeachingPlan")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-bell-circle"></i>
                                <span> 临时教学计划 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("AdhocIndex", "TeachingPlan" , new { area="TeachingPlan" })"><i class="fa fa-search" aria-hidden="true"></i> 查询临时计划</a>
                                </li>


                            </ul>
                        </li>


                        <li class="@Html.IsSelected(controller: "Order")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-account-card-details"></i>
                                <span> 我的 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "Profile", new { area = "Profile" })">
                                        @*<i class="fa fa-flag " aria-hidden="true"></i>*@
                                        @*<span class="badge badge-info badge-pill float-right">40</span>*@
                                        <span> 我的资料 </span>
                                    </a>

                                </li>

                            </ul>
                        </li>






                    }
                    @if (admin)
                    {
                        <li class="@Html.IsSelected(controller: "Teacher")">
                            <a href="javascript: void(0);">
                                <i class="fe-user-minus"></i>
                                <span> 教师管理 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li class="@Html.IsSelected(controller: "Teacher",action:"Index")">
                                    <a href="@Url.Action("Index", "Teacher", new { area = "Teacher" })"><i class="fa fa-search" aria-hidden="true"></i> 查询</a>
                                </li>
                                <li class="@Html.IsSelected(controller: "Teacher",action:"Upload")">
                                    <a href="@Url.Action("Upload", "Teacher", new { area = "Teacher" })"><i class="fa fa-upload" aria-hidden="true"></i> 上传</a>
                                </li>

                            </ul>
                        </li>

                        <li class="@Html.IsSelected(controller: "Student")">
                            <a href="javascript: void(0);">
                                <i class="fe-users"></i>
                                <span> 学生管理 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">

                                <li class="@Html.IsSelected(controller: "Student",action:"Index")">
                                    <a href="@Url.Action("Index", "Student", new { area = "Student" })"><i class="fa fa-search" aria-hidden="true"></i> 查询</a>
                                </li>
                                <li class="@Html.IsSelected(controller: "Student",action:"Upload")">
                                    <a href="@Url.Action("Upload", "Student", new { area = "Student" })"><i class="fa fa-upload" aria-hidden="true"></i> 上传</a>
                                </li>

                            </ul>
                        </li>

                        <li class="@Html.IsSelected(controller: "Subject")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-view-module"></i>
                                <span> 科目管理 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "Subject" , new { area="Subject" })"><i class="fa fa-search" aria-hidden="true"></i> 查询</a>
                                </li>
                            </ul>
                        </li>
                        <li class="@Html.IsSelected(controller: "ClassRoom")">
                            <a href="javascript: void(0);">
                                <i class="mdi mdi-google-classroom"></i>
                                <span> 教室管理 </span>
                                <span class="menu-arrow"></span>
                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "ClassRoom", new { area = "ClassRoom" })"><i class="fa fa-search" aria-hidden="true"></i> 查询</a>
                                </li>
                            </ul>
                        </li>

                    
                        <li class="@Html.IsSelected(controller: "CodeManager,Holiday")">
                            <a href="javascript: void(0);">
                                <i class="fe-settings"></i>
                                <span> 系统设置 </span>
                                <span class="menu-arrow"></span>
                            </a>

                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "CodeManager", new { area = "Code" })"><i class="fa fa-user-cog" aria-hidden="true"></i> 参数管理</a>
                                </li>


                            </ul>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "Holiday", new { area = "Code" })"><i class="mdi mdi-calendar-star" aria-hidden="true"></i> 假期管理</a>
                                </li>


                            </ul>
                        </li>

                        <li>
                            <a href="javascript: void(0);">
                                <i class="fe-trending-up"></i>
                                <span class="badge badge-primary float-right">New</span>
                                <span> 统计报表 </span>

                            </a>
                            <ul class="nav-second-level" aria-expanded="false">
                                <li>
                                    <a href="@Url.Action("Index", "Home" , new { area="" })">
                                        <i class="fe-activity"></i>

                                        <span> 课程统计 </span>
                                    </a>

                                </li>


                            </ul>
                        </li>
                    }
                   

                </ul>

            </div>
            <!-- End Sidebar -->

            <div class="clearfix"></div>

        </div>
        <!-- Sidebar -left -->

    </div>
    <!-- Left Sidebar End -->



}
